主题
回放控制 - InputPlayback
函数简介
按录制 JSONL 中的相对时间 t_ms 回放键鼠。典型流程:LOAD → START →(可选 PAUSE / SEEK / STOP)→ FREE。
需要 InputSync 权限。路径相对 WorkPath;非 LOAD 动作 path 传 ""。
接口名称
InputPlaybackDLL调用
c
long InputPlayback(long instance, long handle, int action, string path, double speed, long seek_ms, int flags);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。在该实例上执行回放。 |
| handle | 长整数型 | 回放句柄;LOAD 时可传 0。 |
| action | 整数型 | 见下表。 |
| path | 字符串 | LOAD 时的 JSONL 路径;其它动作传 ""。 |
| speed | 双精度 | START 播放倍率,<=0 视为 1.0。 |
| seek_ms | 长整数型 | SEEK 目标相对时间(毫秒)。 |
| flags | 整数型 | START 时可选标志位或。 |
action
| 值 | 常量 | 说明 |
|---|---|---|
| 1 | LOAD | 加载文件,返回 handle(>0) |
| 2 | START | 开始播放 |
| 3 | PAUSE | 暂停 |
| 4 | STOP | 停止本次播放(句柄仍可用) |
| 5 | SEEK | 跳转 |
| 6 | FREE | 释放句柄(必须) |
START flags
| 值 | 含义 |
|---|---|
| 0x1 | MONITOR:回放事件也进 InputMonitor |
| 0x2 | BROADCAST:再广播给已绑定从实例 |
| 0x4 | LOOP:播完从起点循环,直到 STOP/FREE |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long long h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4); // START + LOOP
// ...
ola.InputPlayback(h, 4, "", 0, 0, 0); // STOP
ola.InputPlayback(h, 6, "", 0, 0, 0); // FREEcsharp
using OLAPlug;
var ola = new OLAPlugServer();
long h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
h := ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let h = ola.input_playback(0, 1, "input_rec/demo.jsonl", 0.0, 0, 0);
ola.input_playback(h, 2, "", 1.0, 0, 4);
ola.input_playback(h, 4, "", 0.0, 0, 0);
ola.input_playback(h, 6, "", 0.0, 0, 0);cpp
var ola = com("OlaPlug.OlaSoft")
var h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)text
.局部变量 ola, OLAPlug
ola.创建 ()
h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int64_t h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long h = InputPlayback(instance, 0, 1, "input_rec/demo.jsonl", 0, 0, 0);
InputPlayback(instance, h, 2, "", 1.0, 0, 4);
InputPlayback(instance, h, 4, "", 0, 0, 0);
InputPlayback(instance, h, 6, "", 0, 0, 0);csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long InputPlayback(long instance, long handle, int action, string path, double speed, long seek_ms, int flags);
long instance = CreateCOLAPlugInterFace();
long h = InputPlayback(instance, 0, 1, "input_rec/demo.jsonl", 0, 0, 0);
InputPlayback(instance, h, 2, "", 1.0, 0, 4);
InputPlayback(instance, h, 4, "", 0, 0, 0);
InputPlayback(instance, h, 6, "", 0, 0, 0);python
from ctypes import CDLL, c_int64, c_double
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.InputPlayback.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
h = ola.InputPlayback(instance, 0, 1, b"input_rec/demo.jsonl", c_double(0), 0, 0)
ola.InputPlayback(instance, h, 2, b"", c_double(1.0), 0, 4)
ola.InputPlayback(instance, h, 4, b"", c_double(0), 0, 0)
ola.InputPlayback(instance, h, 6, b"", c_double(0), 0, 0)返回值
| 返回值 | 说明 |
|---|---|
>0 | LOAD 成功,返回回放句柄。 |
1 | 其它动作成功。 |
0 或负值 | 失败。 |
